package com.ruoyi.utils;

import java.io.File;

public class MyFileUtils {

    /**
     * 删除文件
     *
     * @param filePath 文件
     * @return
     */
    public static boolean deleteFile(String filePath)
    {
        // /profile/upload/2024/09/05/gxb_20240905105418A002.png
        String startPath = "C:/Object/adv/files";
        boolean flag = false;
        if(filePath != null) {
            String subFilePath = filePath.replaceAll("/profile", "");
            String newFilePath = startPath + subFilePath;
            File file = new File(newFilePath);
            // 路径为文件且不为空则进行删除
            if (file.isFile() && file.exists())
            {
                System.out.println("删除的文件路径==========>" + newFilePath);
                flag = file.delete();
            }
        }
        return flag;
    }

}
